package com.esri.core.analysis;

import com.esri.core.geometry.Point;
import com.esri.core.internal.util.c;
import com.esri.core.internal.util.g;
import com.esri.core.raster.FunctionRasterSource;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.LinkedList;

/* loaded from: classes.dex */
public class Viewshed implements Function {
    private long a;
    private final String b = "Viewshed";

    @Override // com.esri.core.analysis.Function
    public String getName() {
        return "Viewshed";
    }

    native void nativeClose(long j);

    native long nativeCreate(String str, String str2);

    native double[] nativeGetObserver(long j);

    native double nativeGetObserverZOffset(long j);

    /* JADX INFO: Access modifiers changed from: package-private */
    public native void nativeSetNoDataColor(long j, int i);

    /* JADX INFO: Access modifiers changed from: package-private */
    public native void nativeSetNonVisibleColor(long j, int i);

    native void nativeSetObserver(long j, double d, double d2);

    native void nativeSetObserverZOffset(long j, double d);

    /* JADX INFO: Access modifiers changed from: package-private */
    public native void nativeSetVisibleColor(long j, int i);

    static {
        if (System.getProperty("java.runtime.name").contains("Android")) {
            System.loadLibrary("RSSupport");
            System.loadLibrary("rs.main");
            System.loadLibrary("render_script_analysis");
        }
    }

    public Viewshed(String str) throws IllegalArgumentException, FileNotFoundException, RuntimeException {
        this.a = 0L;
        System.out.println("The Viewshed class is marked as Beta functionality at the 10.2.4 release. Please send us your feedback on this functionality through the public forums. Please see license information.");
        if (g.a(str)) {
            throw new IllegalArgumentException("The path to the raster data cannot be null or empty string.");
        }
        if (!new File(str).exists()) {
            throw new FileNotFoundException("Could not find file located at: " + str);
        }
        try {
            this.a = nativeCreate(str, c.a().getAbsolutePath());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public FunctionRasterSource getOutputFunctionRasterSource() {
        FunctionRasterSource functionRasterSource = new FunctionRasterSource();
        LinkedList<Function> linkedList = new LinkedList<>();
        linkedList.add(this);
        functionRasterSource.setFunctions(linkedList);
        return functionRasterSource;
    }

    public Point getObserver() {
        double[] nativeGetObserver;
        long j = this.a;
        if (j == 0 || (nativeGetObserver = nativeGetObserver(j)) == null || nativeGetObserver.length != 3) {
            return null;
        }
        return new Point(nativeGetObserver[0], nativeGetObserver[1], nativeGetObserver[2]);
    }

    public void setObserver(Point point) {
        if (this.a == 0 || point == null || point.isEmpty()) {
            return;
        }
        nativeSetObserver(this.a, point.getX(), point.getY());
    }

    public double getObserverZOffset() {
        long j = this.a;
        if (j != 0) {
            return nativeGetObserverZOffset(j);
        }
        return -1.0d;
    }

    public void setObserverZOffset(double d) {
        long j = this.a;
        if (j != 0) {
            nativeSetObserverZOffset(j, d);
        }
    }

    @Override // com.esri.core.analysis.Function
    public long getId() {
        return this.a;
    }

    @Override // com.esri.core.analysis.Function
    public void dispose() {
        long j = this.a;
        if (j != 0) {
            nativeClose(j);
            this.a = 0L;
        }
    }

    protected void finalize() throws Throwable {
        super.finalize();
        dispose();
    }
}
